/*
 * PKL 51 GUNUNG KIDUL
 * Subseksie DATA ENTRY + CAPI
 */
package pkl51.validasi;

import java.util.List;
import javax.swing.JOptionPane;
import pkl51.component.TextField;
import pkl51.view.FormUtama;
import pkl51.view.PanelKuesioner;

/**
 *
 * @author Hindarwan
 */
public class AbstractValidasi {
    protected List<TextField> list;

    public void setListTextFields(List<TextField> listTextFields) {
        this.list= listTextFields;
    }
    
    public void errorMessage(String message){
        JOptionPane.showMessageDialog(FormUtama.getInstance(), message, "Error", JOptionPane.ERROR_MESSAGE);
    }
    
    public void skipTo(List<TextField> list, int from, int to){
        for (int i = from; i < to; i++) {
            list.get(i).setEnabled(false);
        }
    }
    
    public String previousValue(TextField field){
        String value = list.get(list.indexOf(field) - 1).getText();
        return value;
    }
    public String nextValue(TextField field){
        String value = list.get(list.indexOf(field) + 1).getText();
        return value;
    }
    
    
}
